package service;

import java.util.*;

import beans.*;
import db.*;

public class adminService {
	public boolean login(String account,String password)
	{
		adminDAO adminDao=new adminDAO();
		return adminDao.valid(account, password);
	}
	
	public List<adminBean> browse(){
		adminDAO dao =new adminDAO();
		return dao.getAllRecords();
	}
	
	public boolean addadmin(adminBean admin)
	{
		adminDAO adminDao=new adminDAO();
		return adminDao.insertRecord(admin);
	}
	
	public adminBean getRecord(String adminId)
	{
		adminDAO adminDao=new adminDAO();
		return adminDao.getRecord(adminId);
	}
	
	public int deladmin(adminBean admin)
	{
		adminDAO adminDao=new adminDAO();
		if(adminDao.deleteRecord(admin))
			return 1;
		else
			return 2;
	}
	
	public int updateadmin(adminBean beforeRecord,adminBean afterRecord)
	{
		adminDAO adminDao=new adminDAO();
		if(adminDao.updateRecord(beforeRecord,afterRecord))
			return 1;
		else
			return 2;
	}
}
